#include "messagebus.hpp"
using namespace std;

struct Test_t
{
	void Test1(int x)
	{
		cout << "Test1:" << x << endl;
	}

	void Test2()
	{
		cout << "Test2" << endl;
	}

	void Test3(int x) const
	{
		cout << "Test3" << endl;
	}
};

void TestString(char* x)
{
	cout << "TestString" << endl;
}

void TestEmpty()
{
	cout << "TestEmpty" << endl;
}

void RandomKey()
{
	cout << "RandomKey" << endl;
}

void TestMessageBus()
{
	Test_t a;
	MessageBus<> bus;
	bus.Attach<int>("Test1", &Test_t::Test1, &a);
	int x = 3;
	bus.SendReq("Test1", 3);

	bus.Attach<int>("Test3", &Test_t::Test3, &a);
	bus.SendReq("Test3", x);

	bus.Attach("Test2", &Test_t::Test2, &a);
	bus.SendReq("Test2");

	bus.Attach<char*>("TestString", TestString);
	bus.SendReq("TestString", (char*)"TestString");

	bus.Attach("empty", TestEmpty);
	bus.SendReq("empty");

	const string& key = bus.RandomKey();
	bus.Attach(key, RandomKey);
	bus.SendReq(key);
	bus.Remove(key);
	bus.SendReq(key);
}

int main()
{
	TestMessageBus();
	return 0;
}